/*
 * Copyright (C) 2014 VenomVendor <info@VenomVendor.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.naizhuai.ui.adapter.business;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.naizhuai.R;
import com.naizhuai.ui.components.CircleImageView;
import com.naizhuai.ui.components.LabelsView;

import java.util.List;

public class TargetDetailsReasonsAdapterHolder extends RecyclerView.Adapter {
    private Context mContext;
    private OnItemClickListener mItemClickListener;
    private List<String> reasons;
    private String strFormat;

    public TargetDetailsReasonsAdapterHolder(Context context, List<String> reasons) {
        this.mContext = context;
        this.reasons = reasons;
        strFormat = context.getString(R.string.number_format);

    }


    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View sView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_target_details_reason_content, parent, false);
        return new ProReasonContentHolder(sView);

    }

    //targetBean
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ProReasonContentHolder) {
            ProReasonContentHolder inputHolder = (ProReasonContentHolder) holder;
            inputHolder.title.setText(String.format(strFormat, position+1, reasons.get(position)));
        }
    }

    @Override
    public int getItemCount() {
        return reasons.size();
    }

    public class ProReasonContentHolder extends RecyclerView.ViewHolder {
        TextView title;

        public ProReasonContentHolder(View view) {
            super(view);
            title = (TextView) view.findViewById(R.id.reason_items);
        }
    }


    public interface OnItemClickListener {
        void onItemClick(View view, int position, int listIndex);
    }

    public void setOnItemClickListener(OnItemClickListener mItemClickListener) {
        this.mItemClickListener = mItemClickListener;
    }
}
